import 'package:equatable/equatable.dart';
import 'package:backend.purchases/domain/entities/yookassa_api/payments/yookassa_api_bank_card_type.dart';

const kYookassaApiBankCardTypeVisaValue = 'Visa';
const kYookassaApiBankCardTypeMastercardValue = 'MasterCard';
const kYookassaApiBankCardTypeMirValue = 'Mir';
const kYookassaApiBankCardTypeUnionPayValue = 'UnionPay';
const kYookassaApiBankCardTypeJcbValue = 'JCB';
const kYookassaApiBankCardTypeAmericanExpressValue = 'AmericanExpress';
const kYookassaApiBankCardTypeDinersClubValue = 'DinersClub';
const kYookassaApiBankCardTypeDiscoverCardValue = 'DiscoverCard';
const kYookassaApiBankCardTypeInstaPaymentValue = 'InstaPayment';
const kYookassaApiBankCardTypeInstaPaymentTMValue = 'InstaPaymentTM';
const kYookassaApiBankCardTypeLaserValue = 'Laser';
const kYookassaApiBankCardTypeDankortValue = 'Dankort';
const kYookassaApiBankCardTypeSoloValue = 'Solo';
const kYookassaApiBankCardTypeSwitchValue = 'Switch';
const kYookassaApiBankCardTypeUnknownValue = 'Unknown';

class YookassaApiBankCardTypeDto extends Equatable {
  const YookassaApiBankCardTypeDto._internal({
    required this.bankCardTypeString,
  });

  final String bankCardTypeString;

  @override
  List<Object?> get props {
    return [
      bankCardTypeString,
    ];
  }

  factory YookassaApiBankCardTypeDto.fromString(String bankCardTypeString) {
    return YookassaApiBankCardTypeDto._internal(
      bankCardTypeString: bankCardTypeString,
    );
  }

  YookassaApiBankCardType toEntity() {
    if (bankCardTypeString == kYookassaApiBankCardTypeVisaValue) {
      return YookassaApiBankCardType.visa;
    }

    if (bankCardTypeString == kYookassaApiBankCardTypeMastercardValue) {
      return YookassaApiBankCardType.mastercard;
    }

    if (bankCardTypeString == kYookassaApiBankCardTypeMirValue) {
      return YookassaApiBankCardType.mir;
    }

    if (bankCardTypeString == kYookassaApiBankCardTypeUnionPayValue) {
      return YookassaApiBankCardType.unionPay;
    }

    if (bankCardTypeString == kYookassaApiBankCardTypeJcbValue) {
      return YookassaApiBankCardType.jcb;
    }

    if (bankCardTypeString == kYookassaApiBankCardTypeAmericanExpressValue) {
      return YookassaApiBankCardType.americanExpress;
    }

    if (bankCardTypeString == kYookassaApiBankCardTypeDinersClubValue) {
      return YookassaApiBankCardType.dinersClub;
    }

    if (bankCardTypeString == kYookassaApiBankCardTypeDiscoverCardValue) {
      return YookassaApiBankCardType.discoverCard;
    }

    if (bankCardTypeString == kYookassaApiBankCardTypeInstaPaymentValue) {
      return YookassaApiBankCardType.instaPayment;
    }

    if (bankCardTypeString == kYookassaApiBankCardTypeInstaPaymentTMValue) {
      return YookassaApiBankCardType.instaPaymentTM;
    }

    if (bankCardTypeString == kYookassaApiBankCardTypeLaserValue) {
      return YookassaApiBankCardType.laser;
    }

    if (bankCardTypeString == kYookassaApiBankCardTypeDankortValue) {
      return YookassaApiBankCardType.dankort;
    }

    if (bankCardTypeString == kYookassaApiBankCardTypeSoloValue) {
      return YookassaApiBankCardType.solo;
    }

    if (bankCardTypeString == kYookassaApiBankCardTypeSwitchValue) {
      return YookassaApiBankCardType.switchCard;
    }

    if (bankCardTypeString == kYookassaApiBankCardTypeUnknownValue) {
      return YookassaApiBankCardType.unknown;
    }

    throw UnimplementedError();
  }
}
